// This code is hosted on http://code.google.com/p/lenthorp/
// Freely available for use in applications, but should NOT be modified
// Email all comments to lenthorpresearch@gmail.com


/*! \file generalstochasticprocessarray.hpp
    \brief Array of correlated stochastic processes
*/

#ifndef quantlib_general_stochastic_process_array_hpp
#define quantlib_general_stochastic_process_array_hpp

//#include <ql/quantlib.hpp>

#include <ql/stochasticprocess.hpp>
#include <vector>

namespace QuantLib {

    //! %Array of correlated 1-D stochastic processes
    /*! \ingroup processes */
    class GeneralStochasticProcessArray : public StochasticProcess {
      public:
        GeneralStochasticProcessArray(
                  const std::vector<boost::shared_ptr<StochasticProcess> >&,
                  const Matrix& correlation);
        // stochastic process interface
        Size size() const;
        Disposable<Array> initialValues() const;
        Disposable<Array> drift(Time t, const Array& x) const;
        //Disposable<Array> expectation(Time t0, const Array& x0, Time dt) const;

        Disposable<Matrix> diffusion(Time t, const Array& x) const;
        Disposable<Matrix> covariance(Time t0, const Array& x0, Time dt) const;
        //Disposable<Matrix> stdDeviation(Time t0, const Array& x0,
        //                                Time dt) const;

        //Disposable<Array> apply(const Array& x0, const Array& dx) const;
        Disposable<Array> evolve(Time t0, const Array& x0,
                                  Time dt, const Array& dw) const;

        Time time(const Date&) const;
        // inspectors
        const boost::shared_ptr<StochasticProcess>& process(Size i) const;
        Disposable<Matrix> correlation() const;
      protected:
        std::vector<boost::shared_ptr<StochasticProcess> > processes_;
        Matrix sqrtCorrelation_;
    };

}


#endif
